<?php
/**
 * +----------------------------------------------------------------------
 * | 九月科技-ztuc.cn
 * +----------------------------------------------------------------------
 *                      .::::.
 *                    .::::::::.            | AUTHOR: siyu
 *                    :::::::::::           | EMAIL: ztucke@ztuc.cn
 *                 ..:::::::::::'           | DATETIME: 2020/01/31
 *             '::::::::::::'
 *                .::::::::::
 *           '::::::::::::::..
 *                ..::::::::::::.
 *              ``::::::::::::::::
 *               ::::``:::::::::'        .:::.
 *              ::::'   ':::::'       .::::::::.
 *            .::::'      ::::     .:::::::'::::.
 *           .:::'       :::::  .:::::::::' ':::::.
 *          .::'        :::::.:::::::::'      ':::::.
 *         .::'         ::::::::::::::'         ``::::.
 *     ...:::           ::::::::::::'              ``::.
 *   ```` ':.          ':::::::::'                  ::::..
 *                      '.:::::'                    ':'````..
 * +----------------------------------------------------------------------
 */
/**
 * Created by PhpStorm.
 * Tourist: Administrator
 * Date: 2020/4/10
 * Time: 21:59
 */

namespace app\store\model;
use app\store\model\core\InitModel;
use think\model\concern\SoftDelete;

/**
 * 点赞记录
 * Class Tourist
 * @package app\model\admin
 */
class UserRule extends InitModel
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;
    // 定义表
    protected $name = 'user_rule';

     // 第一自动写入时间字段
    protected $createTime = 'create_time';

    // //前 端 左 侧 菜 单 功 能
    public static function menuRule($uid)
    {
        $group = \app\lnadmin\model\admin\UserGroup::findName($uid);
         // 读取管理员当前拥有的权限节点
        $user_id = explode(',',$group['rules']);
          // 初始化模型
        $model = self::where(['ismenu' => 1, 'status' => 1])
            ->whereIn('id',$user_id)->order('weigh','asc')->field(['id','pid','name as title','url_name as href','icon','weigh','status','create_time','ismenu as type','openType'])
            ->select()->toArray();

        return list_to_tree($model);
    }
   
}